package com.cscj.android.repository.settings.impl

import androidx.room.withTransaction
import com.cscj.android.repository.db.CacheDatabase
import com.cscj.android.repository.repo.favorites.FavoritesRepository
import com.cscj.android.repository.repo.history.BrowserHistoryRepository
import com.cscj.android.repository.settings.Settings
import org.koin.core.component.KoinComponent
import org.koin.core.component.inject

class SettingsImpl : Settings, KoinComponent {

    private val database: CacheDatabase by inject()

    private val searchSetting by inject<Settings.SearchSetting>()

    private val userAgentSetting by inject<Settings.UserAgentSetting>()

    private val favoritesRepository by inject<FavoritesRepository>()

    private val browserHistoryRepository by inject<BrowserHistoryRepository>()


    override suspend fun init() {
        database.withTransaction {
            searchSetting.init()
            userAgentSetting.init()
            favoritesRepository.init()
            browserHistoryRepository.init()
        }
    }
}